package com.zz.chenko.common.utils;

import org.apache.shiro.codec.Base64;
import org.apache.shiro.crypto.hash.Md5Hash;

/**
 * MD5加密工具类
 *
 * @author Zhong
 * @since 2016年12月31日
 */
public class EncryptUtil {

    public static String getMD5Pwd(String pwd, String salt) {
        return new Md5Hash(pwd, salt).toString();
    }

    public static String base64Encode(String str) {
        String s = str;
        for (int i = 0; i < 2; i++) {
            s = Base64.encodeToString(s.getBytes());
        }
        return s;
    }

    public static String base64Decode(String str) {
        String s = str;
        for (int i = 0; i < 2; i++) {
            s = Base64.decodeToString(s);
        }
        return s;
    }

    public static void main(String[] args) {
        System.out.println(new Md5Hash("1111", "36176250").toString());
        String salt = "36176250";
        String s2 = base64Encode(salt);
        System.out.println(salt);
        System.out.println(s2);
        System.out.println(s2 + EncryptUtil.getMD5Pwd("1111", salt));
    }
}
